package com.fdk.wms.common;

import java.util.HashMap;

import lombok.Data;


@Data
public class R<T> {
    private Integer code;
    private String msg;
    private T data;

    private HashMap<String, Object> exts = new HashMap<>();

    public static <T> R<T> success(T object, String message){
        R<T> r = new R<>();
        r.data = object;
        r.msg = message;
        r.code = 200;
        return r;
    }

    public static <T> R<T> error(String message){
        R<T> r = new R<>();
        r.msg = message;
        return r;
    }

    public static <T> R<T> error(String message, int code){
        R<T> r = new R<>();
        r.msg = message;
        r.code = code;
        return r;
    }
    
    public R<T> add(String key, Object value){
        this.exts.put(key, value);
        return this;
    }
}
